package com.wangdong.mijiqiqi.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.wangdong.mijiqiqi.R;

import java.util.List;

/**
 * 作者：wangdong on 2018/10/18 14:28
 * 邮箱：2100520956@qq.com
 */

public class ShowAdapter extends BaseAdapter {

    private List<Result> lists;


    public ShowAdapter(List<Result> lists) {
        this.lists = lists;
    }
    public void addData(List<Result> lists){
        this.lists.clear();
        this.lists.addAll(lists);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public Object getItem(int position) {
        return lists.get(position);
    }

    @Override
    public long getItemId(int positon) {
        return positon;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHodler;
        if (convertView ==null){
            viewHodler = new ViewHolder();
//            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.one_listview_item, parent, false);
//            viewHodler.titletext = (TextView) convertView.findViewById(R.id.text_view);
//            viewHodler.contenttext = (TextView)convertView.findViewById(R.id.textView2);
            convertView.setTag(viewHodler);
        }else{
            viewHodler = (ViewHolder)convertView.getTag();
        }
        Result data = lists.get(position);
        viewHodler.titletext.setText(data.getLottery_name());
        viewHodler.contenttext.setText(data.getRemarks());

        return convertView;
    }

    private static class ViewHolder{
        TextView titletext;
        TextView contenttext;
    }
}
